package com.bamboo.tool.config;

import com.bamboo.tool.view.ApiNavTool;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;

/**
 * Create by GuoQing
 * Date 2022/1/27 16:26
 * Description
 * @author EDZ
 */
public class BambooToolWindowFactory implements ToolWindowFactory, DumbAware {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        ContentFactory contentFactory =  ApplicationManager.getApplication().getService(ContentFactory.class);
        ApiNavTool currentApisNavTool = new ApiNavTool(project);
        Content currentApisNavToolApis = contentFactory.createContent(currentApisNavTool, "", true);
        toolWindow.getContentManager().addContent(currentApisNavToolApis);
        toolWindow.getContentManager().setSelectedContent(currentApisNavToolApis, false);
    }
}
